<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<script type="text/javascript" src="../assets/vue.js"></script>
	<title>methods Option</title>
</head>
<body>
<h1>methods Option</h1>
<hr>
<div id="app">
	{{a}}
	<p><button @click="add(2)">add</button></p>
	<hr/>
	<btn @click.native="add(3)"></btn>
</div>

<script type="text/javascript">
	var btn={
		template:`<button>组件Add</button>`
	};

	var app=new Vue({
		el:'#app',
		data:{
			a:1
		},
		components:{
			"btn":btn
		},
		methods:{
			add:function(num){
				if(num!=''){this.a+=num}
				else{this.a++}
			}
		}
	})
</script>
</body>
</html>